//
//  TKMyOrderViewController.m
//  Ticket
//
//  Created by 小禹宝宝 on 2017/11/2.
//  Copyright © 2017年 cy55. All rights reserved.
//

#import "TKMyOrderViewController.h"
#import "BLBaseListViewDataController.h"
#import "TKOrderListResquest.h"
#import "NSString+JCKit.h"
#import "TKMyOrderListCell.h"
@interface TKMyOrderViewController ()
@property (nonatomic, strong) BLBaseListViewDataController *dataSource;

@end

@implementation TKMyOrderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"订单列表";
    [self ks_setupLeftBackBarButtonItemWithColor:nil];
    TKOrderListResquest *request = [TKOrderListResquest new];
    if ([self.sell_user_id jc_isValidString]) {
        request.sell_user_id = self.sell_user_id;
    }
    if ([self.goods_id jc_isValidString]) {
        request.goods_id = self.goods_id;
    }
    if ([self.buy_user_id jc_isValidString]) {
        request.buy_user_id = self.buy_user_id;
    }
    
    
    _dataSource = [[BLBaseListViewDataController alloc] initWithRequest:request decodeClass:[TKOrderListResponse class] afterParseCompletion:^(id responseObject) {
        DDLogInfo(@"responseObject ----:%@",responseObject);
        
        DDLogInfo(@"responseObject ---- list:%@",[(TKOrderListResponse *)responseObject list]);
    }];
    
    self.listView.pagingListDataSource = _dataSource;
    self.listView.rowHeight = 160;
    [self.listView registerNib:[UINib nibWithNibName:@"TKMyOrderListCell" bundle:nil] forCellReuseIdentifier:@"TKMyOrderListCell"];
}


#pragma mark - UITableViewDataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.listView.dataItems.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    TKMyOrderListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TKMyOrderListCell" forIndexPath:indexPath];
    TKOrderItem *item = self.listView.dataItems[indexPath.row];
    cell.model = item;
    return cell;
}

#pragma mark - UITableViewDelegate


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//    TKOrderItem *item = self.listView.dataItems[indexPath.row];
//    TKTieziDetailViewController *detailVc = [TKTieziDetailViewController new];
//    detailVc.goodsID = item.id;
//    [KSNavi push:detailVc];
}

@end
